import util from "../../utils/util.js"
/*
 * @Date: 2022-03-11 10:15:15
 * @LastEditTime: 2022-03-11 16:20:34
 */
// components/swiper/swiper.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    bannerData: Array,
    indicatorDots: { type: Boolean, value: true },
    indicatorColor: { type: String, value: 'rgba(0,0,0,.3)' },
    indicatorActiveColor: { type: String, value: '#000000' },
    autoplay: { type: Boolean, value: true },
    circular: { type: Boolean, value: true },
    interval: { type: Number, value: 5000 },
    duration: { type: Number, value: 500 },
  },

  /**
   * 组件的初始数据
   */
  data: {},

  /**
   * 组件的方法列表
   */
  methods: {
    go2goodsDetails(e) {
      const { id } = e.currentTarget.dataset;
      if (!id) return;
      wx.$go2('/pages/goods/goodsDetails/goodsDetails?id=' + id, false);
    },
    goDetail(e) {
      console.log("eeee:",e)
      var link = e.currentTarget.dataset.link;
      var type = e.currentTarget.dataset.type;
      console.log("link:-------", link)
      console.log("type:------", type)
      wx.setStorageSync('link', link)
      //如果是功能页面
      if (type == "function") {
          // wx.navigateTo({
          //     url: '../../pages/function-introduction/function-introduction',
          // })
          return ;
      } else if (type == "gzh") {
          console.log("gzh----------------------------------")
          console.log("link", link)
          wx.navigateTo({
            url: '/pages/recruitDynamics/gzhWebView/gzhWebView?path='+ util.baseEncode(link)
        })
      } else {
          //查找对应的_id
          wx.$cloud.callFunction({
              name: "getIndexInfo",
              data: {
                  sign: 27,
                  type: type,
                  link: link
              }
          }, ).then(res => {
              console.log("res:", res.result.data)
              let temp = res.result.data[0]
              if (!temp) {
                  wx.showToast({
                      title: '该公告未录入,敬请期待',
                      icon: 'none',
                      duration: 2000,
                  })
              } else {
                  var id = temp._id
                  console.log("id------------:", id)
                  //找到对应类型公告
                  if (type == "notice") {
                      wx.navigateTo({
                          url: '/pages/recruitDynamics/Notice_detail/Notice_detail?_id=' + id,
                      })
                  } else if (type == "news") {
                      wx.navigateTo({
                          url: '/pages/recruitDynamics/news_detail/news_detail?_id=' + id,
                      })
                  } else if (type == "policy") {
                      wx.navigateTo({
                          url: '/pages/recruitDynamics/policy_detail/policy_detail?_id=' + id,
                      })
                  } else if (type == "employ_notice") {
                      wx.navigateTo({
                          url: './pages/recruitDynamics/publishList_detail/1?_id=' + id,
                      })
                  }
              }
          })
      }
  },
  },
});
